Tux Paint
version 0.9.20
Extending Tux Paint

Copyright 2002-2008 by Bill Kendrick and others
New Breed Software

bill@newbreedsoftware.com
http://www.tuxpaint.org/

June 14, 2002 - March 27, 2008


If you wish to add or change things like Brushes and Rubber Stamps used by Tux Paint, you can do it fairly easily by simply putting or removing files on your hard disk.

Note: You'll need to restart Tux Paint for the changes to take effect.

Where Files Go

Standard Files

Tux Paint looks for its various data files in its 'data' directory.

Linux and Unix

Where this directory goes depends on what value was set for "DATA_PREFIX" when Tux Paint was built. See INSTALL.txt for details.

By default, though, the directory is:

/usr/local/share/tuxpaint/

If you installed from a package, it is more likely to be:

/usr/share/tuxpaint/

Windows

Tux Paint looks for a directory called 'data' in the same directory as the executable. This is the directory that the installer used when installing Tux Paint e.g.:

C:\Program Files\TuxPaint\data

Mac OS X

Tux Paint stores its data files inside the "Tux Paint" icon (which is actually a special kind of folder on Mac OS X). The following steps explain how to get to the folders within:

  1. Bring up a 'context' menu by holding the [Control] key and clicking the Tux Paint icon the in Finder. (If you have a mouse with more than one button, you can simply right-click the icon.)
  2. Select "Show Contents" from the menu that appears. A new Finder window will appear with a folder inside called "Contents."
  3. Open the "Contents" folder and open the "Resources" folder found inside.
  4. There, you will find the "starters", "stamps" and "brushes" folders. Adding new content to these folders will make the content available to any user that launches this copy (icon) of Tux Paint.

Note: If you install a newer version of Tux Paint (by replacing its icon), you will lose changes made by following the instructions above, so keep backups of your new content (stamps, brushes, etc.).

Tux Paint also looks for files in a "TuxPaint" folder that you can place in your system's "Application Support" folder (found under "Library" at the root of your hard disk):

/Library/Application Support/TuxPaint/

It also looks for files in the user's "Preferences" folder, e.g.:

/Users/(user name)/Library/Preferences/TuxPaint/brushes/

Personal Files

You can also create brushes, stamps, fonts and 'starters' in your own directory (folder) for Tux Paint to find.

Windows

Your personal Tux Paint folder is stored in your "Application Data". For example, on newer Windows (set up for an English-speaking user):

C:\Documents and Settings\(user name)\Application Data\TuxPaint\

Mac OS X

Your personal Tux Paint folder is stored in your "Library" folder:

/Users/(user name)/Library/Application Support/ Tux Paint/

Linux and Unix

Your personal Tux Paint directory is "$(HOME)/.tuxpaint/" (also known as "~/.tuxpaint/".

That is, if your home directory is "/home/karl", then your Tux Paint directory is "/home/karl/.tuxpaint/".

Don't forget the period (".") before the 'tuxpaint'!

To add brushes, stamps fonts, and 'starters,' create subdirectories under your personal Tux Paint directory named "brushes", "stamps", "fonts" and "starters" respectively.

(For example, if you created a brush named "flower.png", you would put it in "~/.tuxpaint/brushes/" under Linux or Unix.)


Brushes

The brushes used for drawing with the 'Brush' and 'Lines' tools in Tux Paint are simply PNG image files.

The alpha (transparency) of the PNG image is used to determine the shape of the brush, which means that the shape can be 'anti-aliased' and even partially-transparent!

Greyscale pixels in the brush PNG will be drawn using the currently-selected color in Tux Paint. Color pixels will be tinted.

Brush images should be no wider than 40 pixels across and no taller than 40 pixels high. (i.e., the maximum size can be 40 x 40.)

Brush Options

Aside from a graphical shape, brushes can also be given other attributes. To do this, you need to create a 'data file' for the brush.

A brush data file is simply a text file containing the options.

The file has the same name as the PNG image, but a ".dat" extension. (e.g., "brush.png"'s data file is the text file "brush.dat" in the same directory.)

Brush Spacing

As of Tux Paint version 0.9.16, you can now specify the spacing for brushes (that is, how often they are drawn). By default, the spacing will be the brush's height, divided by 4.

Add a line containing the line "spacing=N" to the brush's data file, where N is the spacing you want for the brush. (The lower the number, the more often the brush is drawn.)

Animated Brushes

As of Tux Paint version 0.9.16, you may now create animated brushes. As the brush is used, each frame of the animation is drawn.

Lay each frame out across a wide PNG image. For example, if your brush is 30x30 and you have 5 frames, the image should be 150x30.

Add a line containing the line "frames=N" to the brush's data file, where N is the number of frames in the brush.

Note: If you'd rather the frames be flipped through randomly, rather than sequentially, also add a line containing "random" to the brush's data file.

Directional Brushes

As of Tux Paint version 0.9.16, you may now create directional brushes. As the brush is used, different shapes are drawn, depending on the direction the brush is going.

The directional shapes are divided into a 3x3 square in a PNG image. For example, if your brush is 30x30, the image should be 90x90, and each of the direction's shapes placed in a 3x3 grid. The center region is used for no motion. The top right is used for motion that's both up, and to the right. And so on.

Add a line containing the line "directional" to the brush's data file.

Animated Directional Brushes

You may mix both animated and directional features into one brush. Use both options ("frames=N" and "directional"), in separate lines in the brush's "".dat" file.

Lay the brush out so that each 3x3 set of directional shapes are laid out across a wide PNG image. For example, if the brush is 30x30 and there are 5 frames, it would be 450x90. (The leftmost 150x90 pixels of the image represent the 9 direction shapes for the first frame, for example.)

Place the brush image PNGs (and any data text files) in the "brushes" directory.

Note: If your new brushes all come out as solid squares or rectangles, it's because you forgot to use alpha transparency! See the documentation file "PNG.txt" for more information and tips.



Stamps

All stamp-related files go in the "stamps" directory. It's useful to create subdirectories and sub-subdirectories there to organize the stamps. (For example, you can have a "holidays" folder with "halloween" and "christmas" sub-folders.)

Images

Rubber Stamps in Tux Paint can be made up of a number of separate files. The one file that is required is, of course, the picture itself.

As of Tux Paint version 0.9.17, Stamps may be either PNG bitmap images or SVG vector images. They can be full-color or greyscale. The alpha (transparency) channel of PNGs is used to determine the actual shape of the picture (otherwise you'll stamp a large rectangle on your drawings).

PNGs can be any size, and Tux Paint (by default) provides a set of sizing buttons to let the user scale the stamp up (larger) and down (smaller).

SVGs are vector-based, and will be scaled appropriately for the canvas being used in Tux Paint.

Note: If your new PNG stamps all have solid rectangular-shaped outlines of a solid color (e.g., white or black), it's because you forgot to use alpha transparency! See the documentation file "PNG.txt" for more information and tips.

Note: If your new SVG stamps seem to have a lot of whitespace, make sure the SVG 'document' is no larger than the shape(s) within. If they are being clipped, make sure the 'document' is large enough to contain the shape(s). See the documentation file "SVG.txt" for more information and tips.

Advanced Users: The Advanced Stamps HOWTO describes, in detail, how to make PNG images which will scale perfectly when used as stamps in Tux Paint.



Description Text

Text (".TXT") files with the same name as the PNG or SVG. (e.g., "picture.png"'s description is stored in "picture.txt" in the same directory.)

The first line of the text file will be used as the US English description of the stamp's image. It must be encoded in UTF-8.

Language Support

Additional lines can be added to the text file to provide translations of the description, to be displayed when Tux Paint is running in a different locale (like French or Spanish).

The beginning of the line should correspond to the language code of the language in question (e.g., "fr" for French, and "zh_tw" for Traditional Chinese), followed by ".utf8=" and the translated description (encoded in UTF-8).

There are scripts in the "po" directory for converting the text files to PO format (and back) for easy translation to different languages. Therefore you should never add or change translations in the .txt files directly.

If no translation is available for the language Tux Paint is currently running in, the US English text is used.

Windows Users

Use NotePad or WordPad to edit/create these files. Be sure to save them as Plain Text, and make sure they have ".txt" at the end of the filename...


Sound Effects

WAVE (".wav") or OGG Vorbis (".ogg") files with the same name as the PNG or SVG. (e.g., "picture.svg"'s sound effect is the sound file "picture.wav" in the same directory.)

Language Support

For sounds for different locales (e.g., if the sound is someone saying a word, and you want translated versions of the word said), also create WAV or OGG files with the locale's label in the filename, in the form: "STAMP_LOCALE.EXT"

"picture.png"'s sound effect, when Tux Paint is run in Spanish mode, would be "picture_es.wav". In French mode, "picture_fr.wav". And so on...

If no localized sound effect can be loaded, Tux Paint will attempt to load the 'default' sound file. (e.g., "picture.wav")

Note: For descriptive sounds (not sound effects, like a bang or a bird chirping), consider using the Descriptive Sounds, described below.


Descriptive Sound

WAVE (".wav") or OGG Vorbis (".ogg") files with the same name as the PNG or SVG, followed by "_desc" (e.g., "picture.svg"'s descriptive sound is the sound file "picture_desc.ogg" in the same directory.)

Language Support

For descriptions in different languages, also create WAV or OGG files with both "_desc" and the locale's label in the filename, in the form: "STAMP_desc_LOCALE.EXT"

"picture.png"'s descriptive sound, when Tux Paint is run in Spanish mode, would be "picture_desc_es.wav". In French mode, "picture_desc_fr.wav". And so on...

If no localized descriptive sound can be loaded, Tux Paint will attempt to load the 'default' descriptive sound file. (e.g., "picture_desc.wav")


Stamp Options

Aside from a graphical shape, a textual description, and a sound effect, stamps can also be given other attributes. To do this, you need to create a 'data file' for the stamp.

A stamp data file is simply a text file containing the options.

The file has the same name as the PNG or SVG image, but a ".dat" extension. (e.g., "picture.png"'s data file is the text file "picture.dat" in the same directory.)

Colored Stamps

Stamps can be made to be either "colorable" or "tintable."

Colorable

"Colorable" stamps they work much like brushes - you pick the stamp to get the shape, and then pick the color you want it to be. (Symbol stamps, like the mathematical and musical ones, are an example.)

Nothing about the original image is used except the transparency (from "alpha" channel). The color of the stamp comes out solid.

Add a line containing the word "colorable" to the stamp's data file.

Tinted

"Tinted" stamps are similar to "colorable" ones, except the details of the original image are kept. (To put it technically, the original image is used, but its hue is changed, based on the currently-selected color.)

Add a line containing the word "tintable" to the stamp's data file.

Tinting Options:

Depending on the contents of your stamp, you might want to have Tux Paint use one of a numer of methods when tinting it. Add one of the following lines to the stamp's data file:

"tinter=normal" (default)
This is the normal tinting mode. (Hue range is +/- 18 degrees, 27 replace.)
"tinter=anyhue"
This remaps all hues in the stamp. (Hue range is +/- 180 degrees.)
"tinter=narrow"
This like 'anyhue', but a narrower hue angle. (Hue range is +/- 6 degrees, 9 replace.)
"tinter=vector"
This is map 'black through white' to 'black through destination'.

Unalterable Stamps

By default, a stamp can be flipped upside down, shown as a mirror image, or both. This is done using the control buttons below the stamp selector, at the lower right side of the screen in Tux Paint.

Sometimes, it doesn't make sense for a stamp to be flippable or mirrored; for example, stamps of letters or numbers. Sometimes stamps are symmetrical, so letting the user flip or mirror them isn't useful.

To make a stamp un-flippable, add the option "noflip" to the stamp's data file.

To keep a stamp from being mirrored, add a line containing the word "nomirror" to the stamp's data file.

Initial Stamp Size

By default, Tux Paint assumes that your stamp is sized appropriately for unscaled display on a 608x472 canvas. This is the original Tux Paint canvas size, provided by a 640x480 screen. Tux Paint will then adjust the stamp according to the current canvas size and, if enabled, the user's stamp size controls.

If your stamp would be too big or too small, you can specify a scale factor. If your stamp would be 2.5 times as wide (or tall) as it should be, add the option "scale 40%" or "scale 5/2" or "scale 2.5" or "scale 2:5" to your image. You may include an "=" if you wish, as in "scale=40%".

Windows Users

You can use NotePad or WordPad to create these file. Be sure to save it as Plain Text, and make sure the filename has ".dat" at the end, and not ".txt"...

Pre-Mirrored and Flipped Images

In some cases, you may wish to provide a pre-drawn version of a stamp's mirror-image, flipped image, or even both. For example, imagine a picture of a fire truck with the words "Fire Department" written across the side. You probably do not want that text to appear backwards when the image is flipped!

To create a mirrored version of a stamp that you want Tux Paint to use, rather than mirroring one on its own, simply create a second ".png" or ".svg" graphics file with the same name, except with "_mirror" before the filename extension.

For example, for the stamp "truck.png" you would create another file named "truck_mirror.png", which will be used when the stamp is mirrored (rather than using a backwards version of 'truck.png').

As of Tux Paint 0.9.18, you may similarly provide a pre-flipped image with "_flip" in the name, and/or an image that is both mirrored and flipped, by naming it "_mirror_flip".

Note: If the user flips and mirrors an image, and a pre-drawn "_mirror_flip" doesn't exist, but either "_flip" or "_mirror" does, it will be used, and mirrored or flipped, respectively.


Fonts

The fonts used by Tux Paint are TrueType Fonts (TTF).

Simply place them in the "fonts" directory. Tux Paint will load the font and provide four different sizes in the 'Letters' selector when using the 'Text' tool.



'Starters'

'Starter' images appear in the 'New' dialog, along with solid color background choices. (Note: In earlier versions of Tux Paint, they appeared in the 'Open' dialog, together with saved drawings.)

Unlike pictures drawn in Tux Paint by users and then opened later, opening a 'starter' creates a new drawing. When you save, the 'starter' image is not overwritten. Additionally, as you edit your new picture, the contents of the original 'starter' affect it.

Coloring-Book Style

The most basic kind of 'starter' is similar to a picture in a coloring book. It's an outline of a shape which you can then color in and add details to. In Tux Paint, as you draw, type text, or stamp stamps, the outline remains 'above' what you draw. You can erase the parts of the drawing you made, but you can't erase the outline.

To create this kind of 'starter' image, simply draw an outlined picture in a paint program, make the rest of the graphic transparent (that will come out as white in Tux Paint), and save it as a PNG format file.

Note: A common mistake is to make the image black and white, rather than black and transparent. Unless there are transparent zones in the 'starter' image, all drawing done by the user in Tux Paint will be covered up by the 'starter'.

Scene-Style

Along with the 'coloring-book' style overlay, you can also provide a separate background image as part of a 'starter' picture. The overlay acts the same: it can't be drawn over, erased, or affected by 'Magic' tools. However, the background can be!

When the 'Eraser' tool is used on a picture based on this kind of 'starter' image, rather than turning the canvas to a solid color, such as white, it returns that part of the canvas to the original background picture from the 'starter'.

By creating both an overlay and a background, you can create a 'starter' which simulates depth. Imagine a background that shows the ocean, and an overlay that's a picture of a reef. You can then draw (or stamp) fish in the picture. They'll appear in the ocean, but never 'in front of' the reef.

To create this kind of 'starter' picture, simply create an overlay (with transparency) as described above, and save it as a PNG. Then create another image (without transparency), and save it with the same filename, but with "-back" appended to the name. (e.g., "reef-back.png" would be the background ocean picture that corresponds to the "reef.png" overlay, or foreground.)

The 'starter' images should be the same size as Tux Paint's canvas. (See the "Loading Other Pictures into Tux Paint" section of README for details on sizing.) If they are not, they will be stretched, without affecting the shape ("aspect ratio"); however some smudging may be applied to the edges.

Place them in the "starters" directory. When the 'New' dialog is accessed in Tux Paint, the 'starter' images will appear in the screen that appears, after the various solid color choices.

Note: 'Starters' can't be saved over from within Tux Paint, since loading a 'starter' is really like creating a new image. (Instead of being blank, though there's already something there to work with.) The 'Save' command simply creates a new picture, like it would if the 'New' command had been used.

Note: 'Starters' are 'attached' to saved pictures, via a small text file that has the same name as the saved file, but with ".dat" as the extension. This allows the overlay and background, if any, to continue to affect the drawing even after Tux Paint has been quit, or another picture loaded or started. (In other words, if you base a drawing on a 'starter' image, it will always be affected by it.)



Translations

Tux Paint supports numerous languages, thanks to use of the "gettext" localization library. (See OPTIONS for how to change locales in Tux Paint.)

To translate Tux Paint to a new language, copy the translation template file, "tuxpaint.pot" (found in Tux Paint's source code, in the folder "src/po/"). Rename the copy as a ".po" file, with an appropriate name for the locale you're translating to (e.g., "es.po" for Spanish; or "pt_br.po" for Brazilian Portuguese, versus "pt.po" or "pt_pt.po" for Portuguese spoken in Portugal.)

Open the newly-created ".po" file — you can edit in a plain text edtior, such as Emacs, Pico or VI on Linux, or NotePad on Windows. The original English text used in Tux Paint is listed in lines starting with "msgid". Enter your translations of each of these pieces of text in the empty "msgstr" lines directly below the corresponding "msgid" lines. (Note: Do not remove the quotes.)

Example:

msgid "Smudge"
msgstr "Manchar"
 
msgid "Click and move to draw large bricks."
msgstr "Haz clic y arrastra para dibujar ladrillos grandes."

A graphical tool, called poEdit (http://www.poedit.net/), is available for Linux, Windows and Mac OS X.

Note: It is best to always work off of the latest Tux Paint text catalog template ("tuxpaint.pot"), since new text is added, and old text is occasionally changed. The text catalog for the upcoming, unreleased version of Tux Paint can be found in Tux Paint's CVS repository (see: http://www.tuxpaint.org/download/source/cvs/), and on the Tux Paint website at http://www.tuxpaint.org/help/po/.

To edit an existing translation, download the latest ".po" file for that language, and edit it as described above.

You may send new or edited translation files to Bill Kendrick, lead developer of Tux Paint, at: bill@newbreedsoftware.com, or post them to the "tuxpaint-i18n" mailing list (see: http://www.tuxpaint.org/lists/).

Alternatively, if you have an account with SourceForge.net, you can request to be added to the "tuxpaint" project and receive write-access to the CVS source code repository so that you may commit your changes directly.

Note: Additional locale support also requires additions to Tux Paint's source code (/src/i18n.h and /src/i18n.c), and requires updates to the Makefile, to have the ".po" gettext catalog source files compiled into ".mo" files, and installed, for use at runtime.

Alternative Input Methods

As of version 0.9.17, Tux Paint's "Text" tool can provide alternative input methods for some languages. For example, when Tux Paint is running with a Japanese locale, the right [Alt] key can be pressed to cycle between Latin, Romanized Hiragana and Romanized Katakana modes. This allows native characters and words to be entered into the "Text" tool by typing one or more keys on a keyboard with Latin characters (e.g., a US QWERTY keyboard).

To create an input method for a new locale, create a text file with a name based on the locale (e.g., "ja" for Japanese), with ".im" as the extension (e.g., "ja.im").

The ".im" file can have multiple character mapping sections for different character mapping modes. For example, on a Japanese typing system, typing [K] [A] in Hiragana mode generates a different Unicode character than typing [K] [A] in Katakana mode.

List the character mappings in this file, one per line. Each line should contain (separated by whitespace):

Start additional character mapping sections with a line containign the word "section".

Example:

# Hiragana
304B   ka   -
304C   ga   -
304D   ki   -
304E   gi   -
304D:3083   kya   -
3063:305F   tta   -
 
# Katakana
section
30AB   ka   -
30AC   ga   -
30AD   ki   -
30AE   gi   -

Note: Blank lines within the ".im" file will be ignored, as will any text following a "#" (pound/hash) character — it can be used to denote comments, as seen in the example above.

Note: Meanings of the flags are locale-specific, and are processed by the language-specific source code in "src/im.c". For example, "b" is used in Korean to handle Batchim, which may carry over to the next character.

Note: Additional input method support also requires additions to Tux Paint's source code (/src/im.c), and requires updates to the Makefile, to have the ".im" files installed, for use at runtime.